package lab03.test06;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.RandomAccessFile;
import java.util.HashMap;
import java.util.Map;

/**
 * Created by lenovo on 2017/12/1.
 */
public class Test {
    public static void main(String[] args) {
        String path ="d:\\words.txt";
        RandomAccessFile file=null;
        Map<String,Integer> map=new HashMap();
        try {
            file=new RandomAccessFile(path,"r");
            String line=null;
            while ((line=file.readLine())!=null){
                System.out.println(line);
                if(map.get(line)==null){
                    map.put(line,1);
                }else{
                   int count= map.get(line);
                   map.put(line,count+1);
                }
            }
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
